package common

import (
	"errors"
	"fmt"
	"net/http"
	"pusher/internal/biz"
)

func ErrorHandler(err error) (int, any) {
	fmt.Printf("business error is: %v\n", err)

	var e *biz.Error
	switch {
	case errors.As(err, &e):
		return http.StatusOK, biz.Fail(e)
	default:
		return http.StatusInternalServerError, nil
	}
}
